﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "BuiltInStructureFamilies.h"
#include "IFamilyManager.h"
#include "FilePath.h"
#include "IUserTransaction.h"
#include "GcmpBuiltInParameterDefinitions.h"
#include "GbmpBuiltInParameterDefinitionsNew.h"
#include "IFamilyExtrusion.h"
#include "FamilyDocumentUtility.h"
#include "IDocumentManager.h"
#include "IFileExtensions.h"
#include "IParameterValueBool.h"
#include "IParameterDefinitionLibrary.h"
#include "FamStructureTemplateUtility.h"
#include "StructureDefaultFamilyTypes.h"
#include "GbmpBuiltInCategoryUniIdentitiesNew.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

using namespace gcmp;
using namespace gfam;

// 结构墙
#define DEFAULTWALLTYPE_CONCRETEWALL_300 GBMP_TR(L"300mm")
#define DEFAULTWALLTYPE_CONCRETEWALL_400 GBMP_TR(L"400mm")
#define DEFAULTWALLTYPE_CONCRETEWALL_500 GBMP_TR(L"500mm")
#define DEFAULTWALLTYPE_CONCRETEWALL_600 GBMP_TR(L"600mm")

// 变截面结构墙
#define DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_300 GBMP_TR(L"300mm")
#define DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_400 GBMP_TR(L"400mm")
#define DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_500 GBMP_TR(L"500mm")
#define DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_600 GBMP_TR(L"600mm")

// 结构柱矩形柱
#define STRUCTURE_RECT_COLUMN_300_300   GBMP_TR(L"300×300mm")
#define STRUCTURE_RECT_COLUMN_400_400   GBMP_TR(L"400×400mm")
#define STRUCTURE_RECT_COLUMN_400_500   GBMP_TR(L"400×500mm")
#define STRUCTURE_RECT_COLUMN_500_600   GBMP_TR(L"500×600mm")

// 结构柱圆形柱
#define STRUCTURE_CIRCLE_COLUMN_300   GBMP_TR(L"300mm")
#define STRUCTURE_CIRCLE_COLUMN_450   GBMP_TR(L"450mm")
#define STRUCTURE_CIRCLE_COLUMN_600   GBMP_TR(L"600mm")
#define STRUCTURE_CIRCLE_COLUMN_1000   GBMP_TR(L"1000mm")

#define STRUCTURE_RECT_STRIP_FOUNDATION_800_400 GBMP_TR(L"矩形条基_800x400mm")
#define STRUCTURE_RECT_STRIP_FOUNDATION_1000_500 GBMP_TR(L"矩形条基_1000x500mm")
#define STRUCTURE_T_STRIP_FOUNDATION_1000_400_300_300 GBMP_TR(L"T型条基_1000/400/300/300")

namespace
{
    std::wstring GetBuiltInFamilyPath(const std::wstring& familyName)
    {
        const std::wstring familyFileName = familyName + IDocumentManager::Get()->GetFileExtensions()->GetDefaultFamilyFileExt();
        return FilePath::Combine(LogManager::Get()->GetLogsFolder(), familyFileName);
    }

    void AddWallTypeImpl(IFamilyManager* pFamilyManager, const std::wstring& typeName, double dWidth)
    {
        DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

        pFamilyManager->AddFamilyType(typeName);
        pFamilyManager->SetCurrentFamilyType(typeName);

        const IFamilyParameterDefinition* pWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CoreThicknessBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pWidth != nullptr, L"无法获得墙厚度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pWidth, dWidth);

        //内墙面为4
        const IFamilyParameterDefinition* pIntTag = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(InteriorFaceNodeTagBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pIntTag != nullptr, L"无法获得墙Tag参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsInteger(pIntTag, InteriorFaceNodeTag);

        //外墙面为6
        const IFamilyParameterDefinition* pExtTag = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(ExteriorFaceNodeTagBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pExtTag != nullptr, L"无法获得墙Tag参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsInteger(pExtTag, ExteriorFaceNodeTag);
    }

    void AddRectangleColumnTypeImpl(IFamilyManager* pFamilyManager, const std::wstring& typeName
        , double dColumnProfileWidth, double dColumnProfileHeight)
    {
        DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

        pFamilyManager->AddFamilyType(typeName);
        pFamilyManager->SetCurrentFamilyType(typeName);

        const IFamilyParameterDefinition* pPDColumnProfileWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionWidthBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pPDColumnProfileWidth != nullptr, L"无法获得截面宽度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pPDColumnProfileWidth, dColumnProfileWidth);

        const IFamilyParameterDefinition* pPDColumnProfileHeight = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionHeightBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pPDColumnProfileHeight != nullptr, L"无法获得截面高度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pPDColumnProfileHeight, dColumnProfileHeight);
    }

    void AddCircleColumnTypeImpl(IFamilyManager* pFamilyManager, const std::wstring &typeName, double diameter)
    {
        DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

        pFamilyManager->AddFamilyType(typeName);
        pFamilyManager->SetCurrentFamilyType(typeName);

        const IFamilyParameterDefinition* pDiameter = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CircSectionDiameterBuiltInParameter));
        DBG_WARN_AND_RETURN_VOID_UNLESS(pDiameter != nullptr, L"无法获得墙厚度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pDiameter, diameter);
    }
}

void BuiltInStructureFamilies::AddWallType(IDocument* pDoc, const std::wstring& typeName, double dWidth)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    AddWallTypeImpl(pFamilyManager, typeName, dWidth);
}

std::wstring BuiltInStructureFamilies::CreateBuiltInWallFamilyDocument(const std::wstring& familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc != nullptr, L"", L"无法创建Document",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager != nullptr, L"", L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> ut = IUserTransaction::Create(pDoc, GBMP_TR(L"String_Set_Family_Category_Wall"));
        DBG_WARN_AND_RETURN_UNLESS(ut != nullptr, L"", L"无法获得ut",L"GDMPLab",L"2024-03-30");

        //初始化墙族模板，已添加墙厚度，墙高度，内墙面id，外墙面id参数
        FamStructureTemplateUtility::InitWallFamilyDocument(pDoc);

        //给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(DEFAULTWALLTYPE_CONCRETEWALL_300);
        const IFamilyParameterDefinition* pWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CoreThicknessBuiltInParameter));
        DBG_WARN_AND_RETURN_UNLESS(pWidth != nullptr, L"", L"无法获得墙厚度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pWidth, 300);

        // 添加类型
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_CONCRETEWALL_400, 400);
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_CONCRETEWALL_500, 500);
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_CONCRETEWALL_600, 600);

        ut->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"Save family failed! ",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring BuiltInStructureFamilies::CreateBuiltInVariableSectionWallFamilyDocument(const std::wstring& familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc != nullptr, L"", L"无法创建Document",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager != nullptr, L"", L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> ut = IUserTransaction::Create(pDoc, GBMP_TR(L"String_Set_Family_Category_Wall"));
        DBG_WARN_AND_RETURN_UNLESS(ut != nullptr, L"", L"无法获得ut",L"GDMPLab",L"2024-03-30");

        //初始化墙族模板，已添加墙厚度，墙高度，内墙面id，外墙面id参数
        FamStructureTemplateUtility::InitWallFamilyDocument(pDoc, true);

        //给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_300);
        const IFamilyParameterDefinition* pWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CoreThicknessBuiltInParameter));
        DBG_WARN_AND_RETURN_UNLESS(pWidth != nullptr, L"", L"无法获得墙厚度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pWidth, 300);

        // 添加类型
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_400, 400);
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_500, 500);
        AddWallTypeImpl(pFamilyManager, DEFAULTWALLTYPE_VARIABLE_SECTION_CONCRETEWALL_600, 600);

        ut->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"Save family failed! ",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring BuiltInStructureFamilies::CreateBuiltInRectBeamFamilyDocument(const std::wstring& familyName)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM;
    // TODO: 接口？
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建矩形梁族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction != nullptr, L"", L"无法获得opTransaction",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitRectBeamFamilyDocument(pDoc);

        // 添加更多族类型
        FamStructureTemplateUtility::AddRectBeamType(pFamilyManager, DEFAULT_RECT_BEAM_400_800, 400, 800);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_RECT_BEAM_300_600);

        // 生成梁体
        FamStructureTemplateUtility::CreateRectBeamBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring BuiltInStructureFamilies::CreateBuiltInVariableSectionRectBeamFamilyDocument(const std::wstring& familyName)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM;
    // TODO: 接口？
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建变截面梁族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitVariableSectionRectBeamFamilyDocument(pDoc);

        // 添加更多族类型
        FamStructureTemplateUtility::AddVariableSectionRectBeamType(pFamilyManager, DEFAULT_VARIABLE_SECTION_RECT_BEAM_400_900_500mm, 400, 900, 500);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_VARIABLE_SECTION_RECT_BEAM_250_900_500mm);

        // 生成梁体
        FamStructureTemplateUtility::CreateVariableSectionRectBeamBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring BuiltInStructureFamilies::CreateCustomizedProfileBeamFamilyDocument(const std::wstring& familyName, const IPolyCurve* pLoop)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM;

    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建自定义截面梁族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitCustomizedProfileBeamFamilyDocument(pDoc);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_CUSTOMIZED_PROFILE);

        // 生成梁体
        FamStructureTemplateUtility::CreateCustomizedProfileBeamBody(pDoc, pLoop);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}




std::wstring BuiltInStructureFamilies::CreateBuildInRectangleColumnFamilyDocument(const std::wstring& familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc != nullptr, L"", L"文档为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager != nullptr, L"", L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> ut = IUserTransaction::Create(pDoc, GBMP_TR(L"设置族的类别：柱"));
        DBG_WARN_AND_RETURN_UNLESS(ut != nullptr, L"", L"无法获得ut",L"GDMPLab",L"2024-03-30");

        //初始化柱族模板，已添加柱，长，宽高参数
        FamStructureTemplateUtility::InitRectangleColumnFamilyDocument(pDoc);

        //给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(STRUCTURE_RECT_COLUMN_300_300);
        const IFamilyParameterDefinition* pWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionWidthBuiltInParameter));
        DBG_WARN_AND_RETURN_UNLESS(pWidth != nullptr, L"", L"无法获得柱截面宽度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pWidth, 300);
        const IFamilyParameterDefinition* pHeight = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionHeightBuiltInParameter));
        DBG_WARN_AND_RETURN_UNLESS(pHeight != nullptr, L"", L"无法获得柱截面高度参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pHeight, 300);
        AddRectangleColumnTypeImpl(pFamilyManager, STRUCTURE_RECT_COLUMN_400_400, 400, 400);
        AddRectangleColumnTypeImpl(pFamilyManager, STRUCTURE_RECT_COLUMN_400_500, 400, 500);
        AddRectangleColumnTypeImpl(pFamilyManager, STRUCTURE_RECT_COLUMN_500_600, 500, 600);

        ut->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"Save family failed! ",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateBuildInCircleColumnFamilyDocument(const std::wstring &familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc != nullptr, L"", L"文档为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager != nullptr, L"", L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> ut = IUserTransaction::Create(pDoc, GBMP_TR(L"设置族的类别：柱"));
        DBG_WARN_AND_RETURN_UNLESS(ut != nullptr, L"", L"ut为空",L"GDMPLab",L"2024-03-30");

        //初始化柱族模板，已添加柱，长，宽高参数
        FamStructureTemplateUtility::InitCircleColumnFamilyDocument(pDoc);

        //给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(STRUCTURE_CIRCLE_COLUMN_300);
        const IFamilyParameterDefinition* pDiameter = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CircSectionDiameterBuiltInParameter));
        DBG_WARN_AND_RETURN_UNLESS(pDiameter != nullptr, L"", L"无法获得柱截面直径参数",L"GDMPLab",L"2024-03-30");
        pFamilyManager->SetParameterValueAsDouble(pDiameter, 300);
        AddCircleColumnTypeImpl(pFamilyManager, STRUCTURE_CIRCLE_COLUMN_450, 450);
        AddCircleColumnTypeImpl(pFamilyManager, STRUCTURE_CIRCLE_COLUMN_600, 600);
        AddCircleColumnTypeImpl(pFamilyManager, STRUCTURE_CIRCLE_COLUMN_1000, 1000);

        ut->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"Save family failed! ",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateCustomizedProfileColumnFamilyDocument(const std::wstring& familyName, const IPolyCurve* pLoop)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN;

    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建自定义截面柱族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitCustomizedProfileColumnFamilyDocument(pDoc);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_CUSTOMIZED_PROFILE);

        // 生成梁体
        FamStructureTemplateUtility::CreateCustomizedProfileColumnBody(pDoc, pLoop);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateBuiltInFloorFamilyDocument(const std::wstring& familyName)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR;

    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");
    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建板族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitFloorFamilyDocument(pDoc);

        // 添加更多族类型
        FamStructureTemplateUtility::AddFloorType(pFamilyManager, DEFAULT_FLOOR_80, 80);
        FamStructureTemplateUtility::AddFloorType(pFamilyManager, DEFAULT_FLOOR_100, 100);
        FamStructureTemplateUtility::AddFloorType(pFamilyManager, DEFAULT_FLOOR_120, 120);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_FLOOR_60);

        // 生成楼板体
        FamStructureTemplateUtility::CreateFloorBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateBuiltInRaftFoundationFamilyDocument(const std::wstring& familyName)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_STRUCTURE_FOUNDATION;

    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");
    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建筏板基础族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitRaftFoundationFamilyDocument(pDoc);
        // 添加更多族类型
        FamStructureTemplateUtility::AddRaftFoundationType(pFamilyManager, DEFAULT_RAFT_FOUNDATION_800, 800);
        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_RAFT_FOUNDATION_600);

        // 生成筏板体
        FamStructureTemplateUtility::CreateRaftFoundationBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateBuiltInRoofFamilyDocument(const std::wstring& familyName)
{
    UniIdentity category = BuiltInCategoryUniIdentities::BICU_NEW_ROOF;

    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(category, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");
    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建屋顶族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitRoofFamilyDocument(pDoc);
        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_ROOF_60);

        // 生成屋顶体
        FamStructureTemplateUtility::CreateRoofBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring gcmp::BuiltInStructureFamilies::CreateBuiltInPlateHoleFamilyDocument(const std::wstring& familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_PLATE_HOLE, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> ut = IUserTransaction::Create(pDoc, GBMP_TR(L"初始化族：板洞"));
        DBG_WARN_AND_RETURN_UNLESS(ut, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitPlateHoleFamilyDocument(pDoc);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_PLATE_HOLE);

        //生成板洞形体
        FamStructureTemplateUtility::CreatePlateHoleBody(pDoc);
        ut->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

void BuiltInStructureFamilies::AddRectangleColumnType(IDocument* pDoc, const std::wstring& typeName
    , double dColumnProfileWidth, double dColumnProfileHeight)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    pFamilyManager->AddFamilyType(typeName);
    pFamilyManager->SetCurrentFamilyType(typeName);

    const IFamilyParameterDefinition* pPDColumnProfileWidth = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionWidthBuiltInParameter));
    DBG_WARN_AND_RETURN_VOID_UNLESS(pPDColumnProfileWidth != nullptr, L"无法获得截面宽度参数",L"GDMPLab",L"2024-03-30");
    pFamilyManager->SetParameterValueAsDouble(pPDColumnProfileWidth, dColumnProfileWidth);

    const IFamilyParameterDefinition* pPDColumnProfileHeight = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(RectSectionHeightBuiltInParameter));
    DBG_WARN_AND_RETURN_VOID_UNLESS(pPDColumnProfileHeight != nullptr, L"无法获得截面高度参数",L"GDMPLab",L"2024-03-30");
    pFamilyManager->SetParameterValueAsDouble(pPDColumnProfileHeight, dColumnProfileHeight);
}

void gcmp::BuiltInStructureFamilies::AddCircleColumnType(IDocument* pDoc, const std::wstring &typeName, double diameter)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    pFamilyManager->AddFamilyType(typeName);
    pFamilyManager->SetCurrentFamilyType(typeName);

    const IFamilyParameterDefinition* pDiameter = pFamilyManager->GetFamilyParameterDefinition(PARAMETER_UID(CircSectionDiameterBuiltInParameter));
    DBG_WARN_AND_RETURN_VOID_UNLESS(pDiameter != nullptr, L"无法获得墙厚度参数",L"GDMPLab",L"2024-03-30");
    pFamilyManager->SetParameterValueAsDouble(pDiameter, diameter);
}

void gcmp::BuiltInStructureFamilies::AddCustomizedColumnType(IDocument* pDoc, const std::wstring& typeName, const IPolyCurve* pLoop)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    pFamilyManager->AddFamilyType(typeName);
    pFamilyManager->SetCurrentFamilyType(typeName);

    FamStructureTemplateUtility::CreateCustomizedProfileColumnBody(pDoc, pLoop);
}

std::wstring BuiltInStructureFamilies::CreateBuiltInRectWallHoleFamilyDocument(const std::wstring& familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL_HOLE, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"创建内建矩形墙洞族"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitRectWallHoleFamilyDocument(pDoc);

        // 添加更多族类型
        FamStructureTemplateUtility::AddRectWallHoleType(pFamilyManager, DEFAULT_WALL_HOLE_2000_2000, 2000, 2000);

        // 设置当前族类型
        pFamilyManager->SetCurrentFamilyType(DEFAULT_WALL_HOLE_1000_2000);

        // 生成矩形墙洞体
        FamStructureTemplateUtility::CreateRectWallHoleBody(pDoc);

        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}

std::wstring BuiltInStructureFamilies::CreateBuiltInCircleWallHoleFamilyDocument(const std::wstring& familyName)
{
#if 0
    //TODO：即将实现
#endif

    return std::wstring();
}

std::wstring BuiltInStructureFamilies::CreateBuiltInRectStripFoundationFamilyDocument(const std::wstring & familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_STRIP_FOUNDATION, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc, L"", L"pDoc为空",L"GDMPLab",L"2024-03-30");

    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"初始化族：矩形条形基础"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        // 初始化族模板
        FamStructureTemplateUtility::InitRectStripFoundationFamilyDocument(pDoc);
        // 给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(STRUCTURE_RECT_STRIP_FOUNDATION_800_400);
        // 添加更多族类型
        FamStructureTemplateUtility::AddRectStripFoundationType(pFamilyManager, STRUCTURE_RECT_STRIP_FOUNDATION_1000_500, 1000, 500);
        pFamilyManager->SetCurrentFamilyType(STRUCTURE_RECT_STRIP_FOUNDATION_800_400);
        FamStructureTemplateUtility::CreateRectStripFoundationBody(pDoc);
        opTransaction->CommitAndResetHistory();
    }

    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"族文件保存失败",L"GDMPLab",L"2024-03-30");

    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());

    return familyPath;
}


std::wstring BuiltInStructureFamilies::CreateBuiltInTStripFoundationFamilyDocument(const std::wstring & familyName)
{
    IDocument* pDoc = FamilyDocumentUtility::CreateFamilyDocument(BuiltInCategoryUniIdentities::BICU_STRUCTURE_STRIP_FOUNDATION, familyName);
    DBG_WARN_AND_RETURN_UNLESS(pDoc != nullptr, L"", L"文档为空",L"GDMPLab",L"2024-03-30");
    gfam::IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager != nullptr, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    //设置族的类别，添加参数
    {
        OwnerPtr<IUserTransaction> opTransaction = IUserTransaction::Create(pDoc, GBMP_TR(L"初始化族：T型条形基础"), true);
        DBG_WARN_AND_RETURN_UNLESS(opTransaction, L"", L"opTransaction为空",L"GDMPLab",L"2024-03-30");

        FamStructureTemplateUtility::InitTStripFoundationFamilyDocument(pDoc);
        // 给当前类型命名
        pFamilyManager->RenameCurrentFamilyType(STRUCTURE_T_STRIP_FOUNDATION_1000_400_300_300);
        FamStructureTemplateUtility::AddTStripFoundationType(pFamilyManager, STRUCTURE_T_STRIP_FOUNDATION_1000_400_300_300, 1000, 400, 0, 300, 300, 300);
        pFamilyManager->SetCurrentFamilyType(STRUCTURE_T_STRIP_FOUNDATION_1000_400_300_300);

        FamStructureTemplateUtility::CreateTStripFoundationBody(pDoc);
        opTransaction->CommitAndResetHistory();
    }
    const std::wstring familyPath = GetBuiltInFamilyPath(familyName);
    DocumentSaveOptions saveOptions(false);
    DocumentSaveResult saveResult;
    pDoc->SaveAs(familyPath, saveOptions, saveResult);
    DBG_WARN_AND_RETURN_UNLESS(saveResult.Code == DocumentSaveError::Ok, L"", L"Save family failed! ",L"GDMPLab",L"2024-03-30");
    IDocumentManager::Get()->CloseDocument(pDoc->GetRuntimeId());
    return familyPath;
}

bool BuiltInStructureFamilies::AddFloorType(IDocument* pDoc, const std::wstring& familyType, double thickness)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddFloorType(pFamilyManager, familyType, thickness);
}

bool gcmp::BuiltInStructureFamilies::AddRoofType(IDocument* pDoc, const std::wstring& familyType, double thickness)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddRoofType(pFamilyManager, familyType, thickness);
}

bool BuiltInStructureFamilies::AddRaftFoundationType(IDocument* pDoc, const std::wstring& familyType, double thickness)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddRaftFoundationType(pFamilyManager, familyType, thickness);
}

bool BuiltInStructureFamilies::AddRectWallHoleType(IDocument* pDoc, const std::wstring& familyType, double profileWidth, double profileHeight)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddRectWallHoleType(pFamilyManager, familyType, profileWidth, profileHeight);
}

bool BuiltInStructureFamilies::AddRectBeamType(IDocument* pDoc, const std::wstring& familyType, double profileWidth, double profileHeight)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddRectBeamType(pFamilyManager, familyType, profileWidth, profileHeight);
}

void gcmp::BuiltInStructureFamilies::AddCustomizedBeamType(IDocument* pDoc, const std::wstring& typeName, const IPolyCurve* pLoop)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_VOID_UNLESS(pFamilyManager != nullptr, L"无法获得FamilyManager",L"GDMPLab",L"2024-03-30");

    pFamilyManager->AddFamilyType(typeName);
    pFamilyManager->SetCurrentFamilyType(typeName);

    FamStructureTemplateUtility::CreateCustomizedProfileBeamBody(pDoc, pLoop);
}

bool gcmp::BuiltInStructureFamilies::AddRectStripFoundationType(IDocument* pDoc, const std::wstring& familyType, double profileWidth, double profileHeight)
{
    IFamilyManager* pFamilyManager = IFamilyManager::Get(pDoc);
    DBG_WARN_AND_RETURN_UNLESS(pFamilyManager, L"", L"pFamilyManager为空",L"GDMPLab",L"2024-03-30");

    return FamStructureTemplateUtility::AddRectStripFoundationType(pFamilyManager, familyType, profileWidth, profileHeight);
}
